package com.hyp.pay.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.hyp.pay.http.App;
import com.hyp.pay.http.Constants;


public class SPUtil {

    private static final String SHAREDPREFERENCES_NAME = "config";

    public static SharedPreferences getAppSp() {
        return App.getInstance().getSharedPreferences(SHAREDPREFERENCES_NAME, Context.MODE_PRIVATE);
    }

    public static void AppSpClean() {
        App.getInstance().getSharedPreferences(SHAREDPREFERENCES_NAME, Context.MODE_PRIVATE).edit().clear().apply();
    }

    public static void removeKey(String token) {
        App.getInstance().getSharedPreferences(SHAREDPREFERENCES_NAME, Context.MODE_PRIVATE).edit().remove(token).commit();
    }

    public static void setUserid(String userid) {
        getAppSp().edit().putString(Constants.USERID, userid).apply();
    }
    public static String getUserid() {
        return getAppSp().getString(Constants.USERID, "");
    }

    public static void seId(String id) {
        getAppSp().edit().putString(Constants.ID, id).apply();
    }
    public static String getID() {
        return getAppSp().getString(Constants.ID, "");
    }

    public static void removeUserId(String userid) {
        App.getInstance().getSharedPreferences(SHAREDPREFERENCES_NAME, Context.MODE_PRIVATE).edit().remove(userid).commit();
    }

    public static void setSignPayerDiv(String sianname) {
        getAppSp().edit().putString(Constants.SignPayerDiv, sianname).apply();
    }
    public static String getSignPayerDiv() {
        return getAppSp().getString(Constants.SignPayerDiv, "");
    }
//
    public static void setSignFace(String pwd) {
        getAppSp().edit().putString(Constants.SignFace, pwd).apply();
    }
    public static String getSignFace() {
        return getAppSp().getString(Constants.SignFace, "");
    }

    public static void setSignDraweeDiv(String headPic) {
        getAppSp().edit().putString(Constants.SignDraweeDiv, headPic).apply();
    }
    public static String getSignDraweeDiv() {
        return getAppSp().getString(Constants.SignDraweeDiv, "");
    }

    public static void setOrder(String order) {
        getAppSp().edit().putString(Constants.BIANHAO, order).apply();
    }
    public static String getOrder() {
        return getAppSp().getString(Constants.BIANHAO, "");
    }
//
    public static void setSignDraweeName(String sex) {
        getAppSp().edit().putString(Constants.SignDraweeName, sex).apply();
    }
    public static String getSignDraweeName() {
        return getAppSp().getString(Constants.SignDraweeName, "");
    }

    public static void setSignPayervName(String email) {
        getAppSp().edit().putString(Constants.SignPayervName, email).apply();
    }
    public static String getSignPayervName() {
        return getAppSp().getString(Constants.SignPayervName, "");
    }

    public static void setCharge(String charge) {
        getAppSp().edit().putString(Constants.CHARGE, charge).apply();
    }
    public static String getCharge() {
        return getAppSp().getString(Constants.CHARGE, "");
    }
    public static void setShowPage(Boolean isShow){
        getAppSp().edit().putBoolean(Constants.SHOW_PAGE, isShow).apply();
    }
    public static Boolean getShowPage() {
        return getAppSp().getBoolean(Constants.SHOW_PAGE, true);
    }

    public static void setAllCookies(String cookies) {
        getAppSp().edit().putString(Constants.ALLCOOKIEKS, cookies).apply();
    }
    public static String getAllCookies() {
        return getAppSp().getString(Constants.ALLCOOKIEKS, "");
    }

    public static void removeAllcookies(String cookies) {
        App.getInstance().getSharedPreferences(SHAREDPREFERENCES_NAME, Context.MODE_PRIVATE).edit().remove(cookies).commit();
    }
    public static void setPaymode(String paymode) {
        getAppSp().edit().putString(Constants.PAYMODE, paymode).apply();
    }
    public static String getPaymode() {
        return getAppSp().getString(Constants.PAYMODE, "");
    }

    public static void setSignPayerName(String SignPayerName) {
        getAppSp().edit().putString(Constants.SIGNPAYERNAME, SignPayerName).apply();
    }
    public static String getSignPayerName() {
        return getAppSp().getString(Constants.SIGNPAYERNAME, "");
    }

    public static void setDraweeName(String SignDraweeName) {
        getAppSp().edit().putString(Constants.SIGNDRAWEENAME, SignDraweeName).apply();
    }
    public static String getDraweeName() {
        return getAppSp().getString(Constants.SIGNDRAWEENAME, "");
    }


    public static void setUsername(String username) {
        getAppSp().edit().putString(Constants.USERNAME, username).apply();
    }
    public static String getUsername() {
        return getAppSp().getString(Constants.USERNAME, "");
    }

    public static void setLogno(String logno){
        getAppSp().edit().putString(Constants.LOGNO, logno).apply();
    }
    public static String getLogno() {
        return getAppSp().getString(Constants.LOGNO, "");
    }
//    paymentId,paymentTime,moneyFloat,text,pay,SignPayerName,username
    public static void setPaymentId(String paymentId){
        getAppSp().edit().putString(Constants.PAYMENTID, paymentId).apply();
    }
    public static String getPaymentId() {

        return getAppSp().getString(Constants.PAYMENTID, "");
    }

    public static void setPaymentTime(String paymentTime){
        getAppSp().edit().putString(Constants.PAYMENTTIME, paymentTime).apply();
    }
    public static String getPaymentTime() {
        return getAppSp().getString(Constants.PAYMENTTIME, "");
    }

    public static void setMoneyFloat(String moneyFloat){
        getAppSp().edit().putString(Constants.MONEYFLOAT, moneyFloat).apply();
    }
    public static String getMoneyFloat() {
        return getAppSp().getString(Constants.MONEYFLOAT, "");
    }

    public static void setText(String text){
        getAppSp().edit().putString(Constants.TEXT, text).apply();
    }
    public static String getText() {
        return getAppSp().getString(Constants.TEXT, "");
    }

    public static void setShopTradeNo(String ShopTradeNo){
        getAppSp().edit().putString(Constants.SHOPTRADENO, ShopTradeNo).apply();
    }
    public static String getShopTradeNo() {
        return getAppSp().getString(Constants.SHOPTRADENO, "");
    }
//
//
//    public static void setMonthPayment(String monthly){
//        getAppSp().edit().putString(Constants.MONTHLYPAYMENT, monthly).apply();
//    }
//    public static String getMonthPayment() {
//        return getAppSp().getString(Constants.MONTHLYPAYMENT, "");
//    }
//
//
//    public static void setPeriod(String period){
//        getAppSp().edit().putString(Constants.PERIOD, period).apply();
//    }
//    public static String getPeriod() {
//        return getAppSp().getString(Constants.PERIOD, "");
//    }
//
//    public static void setItemId(String period){
//        getAppSp().edit().putString(Constants.ITEM_ID, period).apply();
//    }
//    public static String getItemId() {
//        return getAppSp().getString(Constants.ITEM_ID, "");
//    }
}